<script lang='ts' setup>
// @ts-ignore
import {auth} from '@/service/auth.service'
// @ts-ignore
import {Link, Icon} from '@arco-design/web-vue/es/index'
// @ts-ignore
import LoginPwd from "~/components/templates/login/LoginPwd.vue";
// @ts-ignore
import Register from "~/components/templates/login/Register.vue";
// @ts-ignore
import Reset from "~/components/templates/login/Reset.vue";
// @ts-ignore
import LoginWx from "~/components/templates/login/LoginWx.vue";
import '@/static/css/login.css'

type TypeInfo = 'login-pwd' | 'register' | 'reset' | 'login-wx';
const type = ref('login-pwd' as TypeInfo)

function onClose(): void {
    auth.destroyDiv('login')
}

function onChangeType(value: TypeInfo = 'login-pwd'): void {
    type.value = value
}
</script>
<template>
    <div class="mask" @click="onClose"></div>
    <div class="card flex">
        <div class="form flex-c">
            <div class="top">
                <Icon size="20" class="icon" @click="onClose"/>
            </div>
            <div class="body">
                <LoginPwd v-if="type === 'login-pwd'" @close="onClose" @change="onChangeType"/>
                <Register v-else-if="type === 'register'" @close="onClose"/>
                <Reset v-else-if="type === 'reset'" @close="onClose" @change="onChangeType"/>
                <LoginWx v-else-if="type === 'login-wx'" @close="onClose" @change="onChangeType"/>
            </div>
            <div class="bottom">
                <p v-if="type === 'login-pwd'">
                    <span style="font-size: 13px">还没有账号？</span>
                    <Link theme="primary" @click="onChangeType('register')"> 立即注册</Link>
                </p>
                <p v-else-if="type === 'register'">
                    <span style="font-size: 13px">已有账号？</span>
                    <Link theme="primary" @click="onChangeType('login-pwd')"> 立即登录</Link>
                </p>
                <Link theme="primary" @click="onChangeType('login-pwd')" v-else> 返回登录</Link>
            </div>
        </div>
    </div>
</template>
<style lang="scss" scoped>
@import "@/static/css/login.css";

.mask {
  position: fixed;
  top: 0;
  left: 0;
  background: rgb(29, 33, 41);
  opacity: 0.3;
  width: 100vw;
  height: 100vh;
  z-index: 99;
}

.card {
  width: 470px;
  max-width: 96vw;
  background: var(--color-bg-1);
  border-radius: 20px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 99;
  overflow: hidden;

  .brand {
    height: 100%;
    flex: 1;
    background-size: 100% 100%;
  }

  .form {
    width: 100%;
    height: 100%;
    flex: 1;
    justify-content: space-between;

    .top {
      width: 100%;
      text-align: right;
      padding: 42px 38px 0;

      .icon {
        width: 20px;
        height: 20px;
        cursor: pointer;
      }
    }

    .body {
      width: 100%;
      padding-bottom: 20px;
    }

    .bottom {
      width: 100%;
      height: 64px;
      background: var(--color-neutral-3);
      border-radius: 0 0 20px 0;
      line-height: 64px;
      font-size: 18px;

      font-weight: 500;
      color: var(--color-neutral-10);
      display: flex;
      justify-content: center;
      cursor: pointer;

      p {
        margin: auto;
      }
    }
  }
}
</style>
